from typing import List, Optional
from pydantic import BaseModel, Field
import time


class ReadingPosition(BaseModel):
    user_id: int = Field(..., description="用户ID，必填")
    book_id: int = Field(..., description="图书ID，必填")
    position: int = Field(..., description="阅读位置，必填")
    created_at: int = Field(
        default_factory=lambda: int(time.time()), description="创建时间戳"
    )
    updated_at: int = Field(
        default_factory=lambda: int(time.time()), description="更新时间戳"
    )


class ReadingPositionResponse(BaseModel):
    message: str = Field(default="响应消息", description="响应消息")
    reading_positions_data: Optional[ReadingPosition] = Field(
        ..., description="阅读位置数据"
    )


class ReadingPositionUpdateRequest(BaseModel):
    book_id: int = Field(..., description="图书ID，必填")
    position: int = Field(..., description="阅读位置，必填")
